<?php

namespace common\validate;

class DocumentRelation extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data', 'require');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // CreateDocument 验证场景定义
    public function sceneCreateDocument()
    {
        return $this->append('data', 'require')
            ->append("data.item", "require|array")
            ->append("data.catalogs", "array")
            ->append("data.post_content", "require|array")
            ->append("data.post_content.name", "require")
            ->append("data.relation_data", "require|array")
//            ->append("data.relation_data.relation_id", "require")
            ->append("data.relation_data.relation_type", "require");
    }

    // UpdateDocument 验证场景定义
    public function sceneUpdateDocument()
    {
        return $this->append("param.filter", "require")
            ->append("data", "require");
    }

    // FindDocument 验证场景定义
    public function sceneFindDocument()
    {
        return $this->append("param.filter", "require");
    }

    // DeleteDocument 验证场景定义
    public function sceneDeleteDocument()
    {
        return $this->append("param.filter", "require");
    }

    // SelectCatalogDocuments 验证场景定义
    public function sceneSelectCatalogDocuments()
    {
        return $this
            ->append("param.filter.item_name", "require")
            ->append("param.filter.catalog_name", "require");
    }

}
